package com.gitee.wsl.android.ext.device

import android.os.Build
import androidx.annotation.ChecksSdkIntAtLeast


object VersionExt {
    @ChecksSdkIntAtLeast(parameter = 0)
    fun isAtLeastApiLevel(apiLevel: Int): Boolean {
        return Build.VERSION.SDK_INT >= apiLevel
    }

    /**
     * 转换 SDK 版本 convertSDKVersion(31) = Android 12.0
     * @return SDK 版本
     */
    fun convertSDKVersion(): String {
        return convertSDKVersion(Build.VERSION.SDK_INT)
    }

    /**
     * 转换 SDK 版本 convertSDKVersion(31) = Android 12.0
     * @param sdkVersion SDK 版本
     * @return SDK 版本
     */
    fun convertSDKVersion(sdkVersion: Int): String {
        when (sdkVersion) {
            1 -> return "Android 1.0"
            2 -> return "Android 1.1"
            3 -> return "Android 1.5"
            4 -> return "Android 1.6"
            5 -> return "Android 2.0"
            6 -> return "Android 2.0.1"
            7 -> return "Android 2.1.x"
            8 -> return "Android 2.2.x"
            9 -> return "Android 2.3.0-2"
            10 -> return "Android 2.3.3-4"
            11 -> return "Android 3.0.x"
            12 -> return "Android 3.1.x"
            13 -> return "Android 3.2"
            14 -> return "Android 4.0.0-2"
            15 -> return "Android 4.0.3-4"
            16 -> return "Android 4.1.x"
            17 -> return "Android 4.2.x"
            18 -> return "Android 4.3"
            19 -> return "Android 4.4"
            20 -> return "Android 4.4W"
            21 -> return "Android 5.0"
            22 -> return "Android 5.1"
            23 -> return "Android 6.0"
            24 -> return "Android 7.0"
            25 -> return "Android 7.1.1"
            26 -> return "Android 8.0"
            27 -> return "Android 8.1"
            28 -> return "Android 9.0"
            29 -> return "Android 10.0"
            30 -> return "Android 11.0"
            31 -> return "Android 12.0"
            32 -> return "Android 12.0L"
            33 -> return "Android 13.0"
            34 -> return "Android 14.0"
        }
        return "unknown"
    }
}